package com.enjoyor.soa.traffic.core.efoms.mapper.impl;

import com.enjoyor.soa.traffic.core.efoms.constant.RepairsInfoSqlId;
import com.enjoyor.soa.traffic.core.efoms.domain.RepairsInfo;
import com.enjoyor.soa.traffic.core.efoms.mapper.IRepairsInfoMapper;
import com.enjoyor.soa.traffic.frame.support.mybatis.mapper.impl.BaseMapper;
import com.enjoyor.soa.traffic.util.pojo.Page;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class RepairsInfoMapper extends BaseMapper<RepairsInfo> implements IRepairsInfoMapper{

	@Override
	public Page selectRepairsInfoPage(Page page) {
		// TODO Auto-generated method stub
		return this.selectPageInfo(getSqlName(RepairsInfoSqlId.SQL_SELECT_ALL), page);
	}

	@Override
	public List<RepairsInfo> selectRepairsInfoList(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.selectList(getSqlName(RepairsInfoSqlId.SQL_SELECT_LIST), map);
	}

	@Override
	public int countApplyRepairsInfo(String startTime,String endTime) {
		Map<String,String> map = new HashMap<>();
		map.put("startTime",startTime);
		map.put("endTime",endTime);
		return sqlSessionTemplate.selectOne(getSqlName(RepairsInfoSqlId.SQL_COUNT_APPLY_REPAIRS_INFO));
	}

	/**
	 * 查询当日产生催办记录的报修申请单数量
	 *
	 * @return
	 */
	@Override
	public int countRepPressInfo(String startTime,String endTime) {
		Map<String,String> map = new HashMap<>();
		map.put("startTime",startTime);
		map.put("endTime",endTime);
		return sqlSessionTemplate.selectOne(getSqlName(RepairsInfoSqlId.SQL_COUNT_REP_REMIND_INFO), map);
	}

	@Override
	public List<RepairsInfo> getRepCountForDeptIdAndSum() {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.selectList(getSqlName(RepairsInfoSqlId.SQL_COUNT_REP_FOR_SUM_AND_DEPT));
	}

	@Override
	public List<RepairsInfo> getRepSourceCount(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.selectList(getSqlName(RepairsInfoSqlId.SQL_COUNT_REP_COUNT),map);
	}

	@Override
	public List<RepairsInfo> getRepSourceCountForDept(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.selectList(getSqlName(RepairsInfoSqlId.SQL_COUNT_REP_COUNT_FOR_DEPT),map);
	}

}
